<template>
  <view class="js-dialog">
    <u-popup
      v-model="visibleSync"
      mode="center"
      border-radius="30"
      closeable
      width="80%"
      close-icon="close-circle"
      close-icon-color="#E6E6E6"
      close-icon-size="42"
      @close="closePopup"
    >
      <view class="popup-container">
        <view class="title">{{ title }}</view>
        <view class="content">{{ content }}</view>
        <view class="confirmBtn" @click="handleConfirm">{{ confirmText }}</view>
        <view class="cancelBtn" @click="handleCancel">{{ cancelText }}</view>
      </view>
    </u-popup>
  </view>
</template>

<script>
export default {
  props: {
    show: { type: Boolean, default: false },
    title: { type: String, default: '提示' },
    content: { type: String, default: '-' },
    confirmText: { type: String, default: '确定' },
    cancelText: { type: String, default: '取消' },
  },
  data() {
    return { visibleSync: false };
  },
  watch: {
    show: {
      handler(newVal, oldVal) {
        this.visibleSync = newVal;
      },
      immediate: true,
      deep: true,
    },
  },
  onLoad() {},
  methods: {
    showPopup() {
      this.visibleSync = true;
    },
    closePopup() {
      this.visibleSync = false;
      this.$emit('update:show', false);
    },
    handleConfirm() {
      this.$emit('confirm');
    },
    handleCancel() {
      this.$emit('cancel');
    },
    navigateTo(url) {
      uni.navigateTo({
        url: url,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.js-dialog {
  width: 100%;
}

.popup-container {
  width: 100%;
  padding: 50rpx;
  background-color: #ffffff;
  .title {
    font-size: 36rpx;
    font-weight: bold;
    color: #b7926e;
    text-align: center;
  }
  .content {
    margin-top: 27rpx;
    margin-bottom: 30rpx;
    width: 100%;
    padding: 0;
  }
  .confirmBtn {
    margin: 10rpx auto;
    width: 200rpx;
    height: 72rpx;
    line-height: 72rpx;
    font-size: 28rpx;
    font-weight: bolder;
    color: #b7926e;
    text-align: center;
    background: linear-gradient(90deg, #f1cc82, #ffdd99);
    border-radius: 10rpx;
  }
  .cancelBtn {
    margin: 10rpx auto 0;
    width: 200rpx;
    height: 72rpx;
    line-height: 72rpx;
    font-size: 24rpx;
    font-weight: 400;
    color: #999999;
    text-align: center;
    background-color: transparent;
  }
}
</style>
